{{- define "main" -}}

{{ $pub_type_csl := "" }}
{{ $pub_type_display := "" }}
{{ if .Params.publication_types }}
  {{ if reflect.IsSlice .Params.publication_types }}
    {{ $pub_type_csl = index .Params.publication_types 0 }}
    {{ $pub_type_display = i18n (printf "pub_%s" (strings.Replace $pub_type_csl "-" "_")) | default (strings.Title $pub_type_csl) }}
  {{ end }}
{{ end }}

<div class="pub">

  {{ partial "page_header.html" . }}

  <div class="article-container">

    {{ if .Params.abstract }}
    <h3>{{ i18n "abstract" }}</h3>
    <p class="pub-abstract">{{ .Params.abstract | markdownify }}</p>
    {{ end }}

    {{/* If the type is Uncategorized, hide the type. */}}
    {{ if $pub_type_display }}
    <div class="row">
      <div class="col-md-1"></div>
      <div class="col-md-10">
        <div class="row">
          <div class="col-12 col-md-3 pub-row-heading">{{ i18n "publication_type" }}</div>
          <div class="col-12 col-md-9">
            <a href="{{ (site.GetPage "section" "publication").RelPermalink }}#{{ $pub_type_csl | anchorize }}">
              {{ $pub_type_display }}
            </a>
          </div>
        </div>
      </div>
      <div class="col-md-1"></div>
    </div>
    <div class="d-md-none space-below"></div>
    {{ end }}

    {{ if .Params.publication }}
    <div class="row">
      <div class="col-md-1"></div>
      <div class="col-md-10">
        <div class="row">
          <div class="col-12 col-md-3 pub-row-heading">{{ i18n "publication" }}</div>
          <div class="col-12 col-md-9">{{ .Params.publication | markdownify }}</div>
        </div>
      </div>
      <div class="col-md-1"></div>
    </div>
    <div class="d-md-none space-below"></div>
    {{ end }}

    <div class="space-below"></div>

    <div class="article-style">{{ .Content }}</div>

    {{ partial "page_footer" . }}

  </div>
</div>
{{- end -}}
